#
#
# import pymssql
# import self as self
#
# from Tools.scripts.make_ctype import values
#
# class TestDB():
#
#  def __init__(self):
#
#  try:
#   # db = pymysql.connect("192.168.31.221,1433", "sa", "123456", "btmsFszyy20220420")
#  self.conn = pymssql.connect(host='192.168.31.221',user='sa',password='123456',database='btmsFszyy20220420',charset='utf8')
#
# self.cursor = self.conn.cursor()
#
# self.sql = 'select * from UserDetail'
#
# self.cursor.execute(self.sql)
#
# self.conn.commit()
#
# except Exception as ex:
#
# self.conn.rollback()
#
# raise ex
#
# finally:
#
# self.conn.close()
#
# if __name__ == '__main__':
#
#  test_DB = TestDB()

import pymssql
conn = pymssql.connect(host='192.168.31.221',user='sa',password='123456',database='btmsFszyy20220420',charset='utf8')

#查看连接是否成功

cursor = conn.cursor()

sql = 'select top 1 * from UserDetail'

cursor.execute(sql)

#用一个rs变量获取数据

rs = cursor.fetchall()
print(rs)
